#include <config.h>
#include <display_manager.h>
#include <string.h>

static PT_DispOpr g_ptDispOprHead = NULL;

int RegisterDispOpr(PT_DispOpr ptDispOpr)
{
	PT_DispOpr ptTmp;
	if(g_ptDispOprHead == NULL)
	{
		g_ptDispOprHead = ptDispOpr;
		ptDispOpr->ptNext = NULL;
	}
	else
	{
		ptTmp = g_ptDispOprHead;
		while(ptTmp->ptNext)
		{
			ptTmp = ptTmp->ptNext;
		}
		ptTmp = ptDispOpr;
		ptDispOpr->ptNext = NULL;
	}
	return 0;
}

void ShowDispOpr(void)
{
	PT_DispOpr ptTmp;
	int i = 0;
	
	ptTmp = g_ptDispOprHead;
	while(ptTmp)
	{
		printf("%02d %s\n", i++, ptTmp->name);
		ptTmp = ptTmp->ptNext;
	}
}

PT_DispOpr GetDispOpr(char *name)
{
	PT_DispOpr ptTmp;

	ptTmp = g_ptDispOprHead;
	while(ptTmp)
	{
		if(strcmp(name, ptTmp->name) == 0)
			return ptTmp;
		else
			ptTmp = ptTmp->ptNext;
	}
	return NULL;
}

int DispInit(void)
{
	int iError;

	iError = FBRegister();
	if(iError)
	{
		printf("Fb register error\n");
		return -1;
	}

	return 0;
}

